package org.springframework.boot.autoconfigure.mock;

import com.google.gson.Gson;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.mock.config.MockResponseConfig;
import org.springframework.boot.autoconfigure.mock.core.MockResponseAspect;
import org.springframework.boot.autoconfigure.mock.handler.MockResponseHandler;
import org.springframework.boot.autoconfigure.mock.strategy.JsonValueMockResProcessor;
import org.springframework.boot.autoconfigure.mock.strategy.MethodValueMockResProcessor;
import org.springframework.boot.autoconfigure.mock.strategy.MockResProcessorFactory;
import org.springframework.boot.autoconfigure.mock.strategy.PropertyValueMockResProcessor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * @author: hooware
 * @Date: 2021/12/26 17:34
 * @Description: mock res starter 入口配置类
 */
//@AutoConfigureAfter(RedisAutoConfiguration.class)
@Configuration
@ConditionalOnProperty(prefix = MockResponseConfig.PREFIX, name = "enable", havingValue = "true", matchIfMissing = false)
@EnableConfigurationProperties(MockResponseConfig.class)
@Import({Gson.class, JsonValueMockResProcessor.class, PropertyValueMockResProcessor.class, MethodValueMockResProcessor.class, MockResponseAspect.class})
public class MockResAutoConfiguration {

    @Bean
    public MockResponseHandler mockResponseHandler() {
        return new MockResponseHandler();
    }

    @Bean
    public MockResProcessorFactory lockFactory() {
        return new MockResProcessorFactory();
    }
}
